from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet

from apps.goods.models import GoodsChannel, GoodsChannelGroup
from apps.meiduo_admin.serializers.goods_channels_serializers import GoodsChannelsSerializer, \
    GoodsChannelGroupSerializer
from apps.meiduo_admin.utils.pagenum import PageNum


class GoodsChannels(ModelViewSet):
    serializer_class = GoodsChannelsSerializer
    queryset = GoodsChannel.objects.all().order_by("-create_time")
    pagination_class = PageNum


class GoodsChannelTypes(ListAPIView):
    serializer_class = GoodsChannelGroupSerializer
    queryset = GoodsChannelGroup.objects.all()